﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using ExtAspNet;
using GPCSC.Model;
using NickLee.Common;
using System.Data;

namespace GPCSC.Web.SHFW
{
    public partial class SYS_TZ : PageBase
    {
      
        protected void Page_Load(object sender, EventArgs e)
        {
            btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("至少选择一项！");
            if (!IsPostBack)
            {
                f_bound();
            }
        }
        protected void f_bound()
        {
            CL_USER_S user = reUser();
            DataSet ds = new CL_TZ_S().TzBound(user.CL_USER_SOID.ToString());
            if (ds.Tables.Count > 0)
            {
                //if (ds.Tables[0].Rows.Count > 0)
                //{
                //    foreach (DataRow dr in ds.Tables[0].Rows)
                //    {
                //        #region 收件人信息
                //        DataSet df = new CL_TZ_S().get_CL_TZUSER(dr["CL_TZ_SOID"].ToString());
                //        if (df.Tables.Count > 0)
                //        {
                //            if (df.Tables[0].Rows.Count > 0)
                //            {
                //                foreach (DataRow drs in df.Tables[0].Rows)
                //                {
                //                    dr["SJnames"] += drs["jsname"].ToString()+" ";
                //                }
                //            }
                //        }
                //        #endregion
                //        #region 附件信息
                //        DataSet dss = new CL_TZ_S().getfile(dr["CL_TZ_SOID"].ToString());
                //        if (dss.Tables.Count > 0)
                //        {
                //            if (dss.Tables[0].Rows.Count > 0)
                //            {
                //                dr["FJUrls"] += "<ul>";
                //                foreach (DataRow drf in dss.Tables[0].Rows)
                //                {
                //                    dr["FJUrls"] += "<li><a href='" + drf["TZURL"].ToString() + "' target='_bank' >" + drf["filename"].ToString() + "</a></li>";
                //                }
                //                dr["FJUrls"] += "</ul>";
                //            }
                //        }
 
                //        #endregion
                //    }
                //}
                Grid1.DataSource = ds.Tables[0];
                Grid1.DataBind();
            }
            
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            GPCSC.Webs.databyhtable dh = new GPCSC.Webs.databyhtable();
            Hashtable htable = new Hashtable();
            int count = Grid1.SelectedRowIndexArray.Length;
            if (count > 0)
            {
                foreach (int row in Grid1.SelectedRowIndexArray)
                {
                    htable.Clear();
                    htable.Add("isdels", 1);
                    dh.databyhtables(htable, "update", "CL_TZ_S", "CL_TZ_SOID", Grid1.DataKeys[row][0].ToString());
                }
                f_bound();
                Alert.Show("删除成功!");
            }
            else
            {
                Alert.Show("至少选择一项!");
            }
        }
        public Hashtable f_getElements(Hashtable o_uiTable)
        {
            //UIFactory Get Values as Hashtable:界面工厂获取值，并保存在哈希表
            base.o_uiTable.Clear();
            base.o_uiTable = UIFactory.UIFactory_Get(this);
            return base.o_uiTable;
        }
        public CL_USER_S reUser()
        {

            byte[] userInfo = (byte[])base.o_baseTable[c_obj.s_userInfo];
            Hashtable userInfoTable = CompressData.UnCompressHashtable(userInfo);
            CL_USER_S users = (GPCSC.Model.CL_USER_S)userInfoTable["SYS_USER"];
            return users;
        }
        protected string GetEditUrl(object id)
        {
            return "javascript:" + Window1.GetShowReference("CL_View.aspx?id=" + id);
        }
    }
}